/*
例：
<btn-uploadfile-list
    url="http://localhost:8080/api/File/UpdateaFile"
    v-on: error="回调方法名"
    v-on: success="回调方法名"
>
</btn-uploadfile-list>
*/
//动态
/*
例：
列表页导入按钮组件
<btn-uploadfile-list
    url="http://localhost:8080/api/File/UpdateaFile"
    v-on: error="回调方法名"
    v-on: success="回调方法名"
>
</btn-uploadfile-list>
*/
Vue.component('btn-uploadfile-list', {
    props: ['url', 'text', 'data'],
    data: function () {
        return {
            btntext: this.text,
            // cnmd: {}
        }
    },
    methods: {
        error: function (err, file, fileList) {
            //var response = err.message;
            //var responseObj = $.parseJSON(response);
            //var message = responseObj.message;
            this.$message({ message: "导入失败", type: 'error' });
            this.$emit('error', err, file, fileList);
        },
        success: function (response, file, fileList) {
            // this.cnmd.close();
            if (isSuccess(response)) {
                this.$message({ message: '上传成功!', type: 'success' });
                this.$emit('success', response);
                app.GetPageData(1);
                app.ListItem.currentPage = 1;

            }
            else {
                if (response.message) {
                    this.$message({ message: response.message, type: 'error' });
                    return;
                }
                var msg = "";
                for (var i = 0; i < response.data.length; i++) {
                    msg += "<div>" + response.data[i] + "</div>";
                }

                this.$alert(msg, '错误', {
                    dangerouslyUseHTMLString: true
                });
                // eldment $alert 文字过多显示不全
                setTimeout(function () {
                    $('.el-message-box').scrollTop(0);
                }, 100);
                this.$emit('error', null, file, fileList);
            }
        },
        beforeAvatarUpload: function (file) {
            var extension2 = file.name.split(".")[file.name.split(".").length - 1] === "xlsx";
            if (!extension2) {
                this.$message.error("导入文件只能是 xlsx格式!");
                return false;
            }
            //this.cnmd = this.$loading(myloading);
            return extension2
        }
    },
    mounted: function () {
        if (!this.btntext)
            this.btntext = col.btnImport;
    },
    // template: '<el-form-item >     <el-upload class="upload-demo" name="file" :data="data" :action="host+url" :before-upload="beforeAvatarUpload" :on-success="success" :on-error="error" :show-file-list="false"  accept=".xls,.xlsx" > <el-button type="primary">{{btntext}}</el-button> </el-upload> </el-form-item>'
    template: '<span style="float:left!important">     <el-upload class="upload-demo" name="file" :data="data" :action="host+url" :before-upload="beforeAvatarUpload" :on-success="success" :on-error="error" :show-file-list="false"  accept=".xls,.xlsx" ><img src="/static/images/import.png"> <el-button type="primary">{{btntext}}</el-button> <img src="/static/images/tool-line.png" class="tool-line"></el-upload> </span>'
})


Vue.component('btn-uploadfile-drinput', {
    props: ['url', 'text', 'data'],
    data: function () {
        return {
            btntext: this.text,
            // cnmd: {}
        }
    },
    methods: {
        error: function (err, file, fileList) {
            //var response = err.message;
            //var responseObj = $.parseJSON(response);
            //var message = responseObj.message;
            this.$message({ message: "导入失败", type: 'error' });
            this.$emit('error', err, file, fileList);
        },
        success: function (response, file, fileList) {
            // this.cnmd.close();
            if (isSuccess(response)) {
                this.$message({ message: '上传成功!', type: 'success' });
                this.$emit('success', response);
                app.GetPageData(1);
                app.ListItem.currentPage = 1;

            }
            else {
                if (response.message) {
                    this.$message({ message: response.message, type: 'error' });
                    return;
                }
                var msg = "";
                for (var i = 0; i < response.data.length; i++) {
                    msg += "<div>" + response.data[i] + "</div>";
                }

                this.$alert(msg, '错误', {
                    dangerouslyUseHTMLString: true
                });
                // eldment $alert 文字过多显示不全
                setTimeout(function () {
                    $('.el-message-box').scrollTop(0);
                }, 100);
                this.$emit('error', null, file, fileList);
            }
        },
        beforeAvatarUpload: function (file) {
            var extension2 = file.name.split(".")[file.name.split(".").length - 1] === "xlsx";
            if (!extension2) {
                this.$message.error("导入文件只能是 xlsx格式!");
                return false;
            }
            //this.cnmd = this.$loading(myloading);
            return extension2
        }
    },
    mounted: function () {
        if (!this.btntext)
            this.btntext = col.btnImport;
    },
    template: '<el-form-item >     <el-upload class="upload-demo" name="file" :data="data" :action="host+url" :before-upload="beforeAvatarUpload" :on-success="success" :on-error="error" :show-file-list="false"  accept=".xls,.xlsx" > <el-button type="primary">{{btntext}}</el-button> </el-upload> </el-form-item>'
    //template: '    <el-upload  name="file" :data="data" :action="host+url" :before-upload="beforeAvatarUpload" :on-success="success" :on-error="error" :show-file-list="false"  accept=".xls,.xlsx" ><el-button type="primary">{{btntext}}</el-button> </el-upload>'
})


/**
 * input 页面单文件上传组件，带下载  课件
 */
Vue.component('btn-uploadfile-input-kj', {
    props: ['url', 'text', 'showdownload', 'showupload', 'fileid', 'filename'],
    data: function () {
        return {
            btntext: this.text,//按钮名称
            apiUrl: this.url,//API地址
            fileShowDownLoad: this.showdownload,
            fileshowupload: this.showupload,
            count: 0,
        }
    },
    methods: {
        error: function (err, file, fileList) {
            this.$message({
                message: '文件上传失败',
                type: 'error'
            });
            this.$emit('error', err, file, fileList, true);
        },
        success: function (response, file, fileList) {
            var data = response.data;//成功后的业务数据
            var fileModel = data[0];//第一个文件对象
            this.filename = fileModel.fileName;
            this.fileid = fileModel.id;
            var htmlModel = data[1];//html
            this.$message({ message: '上传成功!', type: 'success' });
            this.$emit('success', response, fileModel.id, fileModel.fileName, htmlModel.id, true, data);
        },
        before: function (file) {
            this.$emit('changelodding', true);
        },
        beforeAvatarUpload: function (file) {
            debugger
            var extension = file.name.split(".")[file.name.split(".").length - 1] === "pptx";
            var extension2 = file.name.split(".")[file.name.split(".").length - 1] === "ppt";
            if (!extension2 && !extension) {
                this.$message.error("导入文件只能是 ppt或pptx格式!");
            }
            return extension2 || extension
        }
    },
    mounted: function () {
        if (!this.btntext)
            this.btntext = col.btnImport;
        if (!this.apiUrl)
            this.apiUrl = API_PPT_UPLOADFILE_PATH;//文件上传API URL
        if (this.fileshowupload != false)
            this.fileshowupload = true;//文件上传API URL
    },

    template: '<div class ="aaa"> <span class="el_upload_span"> <el-form-item  > <el-upload v-show="fileshowupload" class="upload-demo" name="files" :action="apiUrl" :on-progress="before" :on-success="success" :on-error="error" :show-file-list="false" :before-upload="beforeAvatarUpload" accept=".ppt,.pptx" ><a href="javascript:void(0)"><el-button type="success">{{btntext}}</el-button></a>  </el-upload></el-form-item> </span> <a v-show="fileShowDownLoad" :href="downLoadUrl(fileid)"> {{filename}} </a></div> '
    //template: '<div class ="aaa">  <el-upload v-show="fileshowupload" class="upload-demo" name="files" :action="apiUrl" :on-progress="before" :on-success="success" :on-error="error" :show-file-list="false"  accept=".ppt,.pptx" ><a href="javascript:void(0)"><el-button type="success">{{btntext}}</el-button><a  style="margin:0 5px" v-show="fileShowDownLoad" :href="downLoadUrl(fileid)"> {{filename}} </a></a>  </el-upload> </div> '
})


///////////////////////////////////////////
/**
 * 列表页模板下载按钮组件
 * tempname 模板名称
 * text 按钮名称：默认可为空
 */
Vue.component('btn-template-download', {
    props: ['tempname', 'text'],
    data: function () {
        return {
            btntext: this.text,
        }
    },
    methods: {
        click: function () {
            var url = host + "/ImportTemplate/" + this.tempname;
            window.open(url);
        },
    },
    mounted: function () {
        if (!this.btntext)
            this.btntext = col.ImportTemplate;
    },
    template: ' <btn :text="col.btnDownLoad" linetype="3" type="primary" @click="click()"></btn>'
})



///////////////////////////////////////////

//Vue.component('btn-uploadfile-input', {
//    props: ['url', 'text', 'showdownload', 'accept'],
//    data: function () {
//        return {
//            btntext: this.text,//按钮名称
//            apiUrl: this.url,//API地址
//            acceptList: this.accept,
//            fileShowDownLoad: this.showdownload,
//            fileUrl: "",//文件下载地址
//            fileName: "",//文件名称
//            count: 0
//        }
//    },
//    methods: {
//        error: function (err, file, fileList) {
//            this.$message({
//                message: '文件上传失败',
//                type: 'error'
//            });
//            this.$emit('error', err, file, fileList);
//        },
//        success: function (response, file, fileList) {

//            var data = response.data;//成功后的业务数据
//            var fileModel = data[0];//第一个文件对象
//            this.fileName = fileModel.fileName;//
//            this.fileUrl = host + "/api/file/DownLoad?id=" + fileModel.id;

//            this.$message({
//                message: '上传成功!',
//                type: 'success'
//            });
//            this.$emit('success', response, file, fileList, fileUrl);
//        }
//    },
//    mounted: function () {

//        if (!this.btntext)
//            this.btntext = col.btnImport;
//        if (!this.apiUrl)
//            this.apiUrl = host + "/api/File/UploadFile";
//        if (!this.acceptList || this.acceptList === "")
//            this.acceptList ==".xls,.xlsx"
//    },
//    template: '<div class ="aaa">  <el-form-item style="display:inline" > <el-upload class="upload-demo" name="files" :action="apiUrl" :on-success="success" :on-error="error" :show-file-list="false" :limit="1" :accept="acceptList" ><a href="javascript:void(0)">{{btntext}}</a>  </el-upload></el-form-item> <a v-show="fileShowDownLoad" :href="fileUrl">{{fileName}}</a></div> '
//})

/**
 * input 页面单文件上传组件，带下载
 */
Vue.component('btn-uploadfile-input', {
    props: ['url', 'text', 'showdownload', 'showupload', 'fileid', 'filename'],
    data: function () {
        return {
            btntext: this.text,//按钮名称
            apiUrl: this.url,//API地址
            fileShowDownLoad: this.showdownload,
            fileshowupload: this.showupload,
            count: 0,

        }
    },
    methods: {
        error: function (err, file, fileList) {
            this.$message({
                message: '文件上传失败',
                type: 'error'
            });
            this.$emit('error', err, file, fileList);
        },
        success: function (response, file, fileList) {
            var data = response.data;//成功后的业务数据
            var fileModel = data[0];//第一个文件对象
            this.filename = fileModel.fileName;
            this.fileid = fileModel.id;
            this.$message({ message: '上传成功!', type: 'success' });
            this.$emit('success', response, fileModel.id, fileModel.fileName, data);
        }
    },
    mounted: function () {
        if (!this.btntext)
            this.btntext = col.btnImport;
        if (!this.apiUrl)
            this.apiUrl = API_UPLOADFILE_URL;//文件上传API URL
        if (this.fileshowupload != false)
            this.fileshowupload = true;//文件上传API URL
    },
    template: '<div class ="aaa"> <a v-show="fileShowDownLoad" :href="downLoadUrl(fileid)"> {{filename}} </a>  <span class="el_upload_span"> <el-form-item style="display:inline" style="display: inline-block">   <el-upload v-show="fileshowupload" class="upload-demo" name="files" :action="apiUrl" :on-success="success" :on-error="error" :show-file-list="false"   ><a href="javascript:void(0)"><el-button type="success">{{btntext}}</el-button></a>  </el-upload> </span> </el-form-item> </div> '
})


/* 
列表页导出按钮
hotus
2019-6-3 13:42:46

例：
<btn-uploadfile-list 
  url="http://localhost:8080/api/File/UpdateFile"
  v-on:error="回调方法名"
  v-on:success="回调方法名"
 >
 </btn-uploadfile-list>
*/

Vue.component('btn-export-list', {
    props: ['forminline', 'url', 'text', 'linetype'],
    data: function () {
        return {
            btntext: this.text,
        }
    },
    methods: {
        btnExportClick: function () {
            var downloadUrl = "";

            var app = this;
            myAjax("Post", null, this.url, this.forminline, function (result, status, xhr) {
                var fileName = result.data;
                var url = host + "/" + fileName;
                window.open(url);
                app.$message({
                    message: '导出成功!',
                    type: 'success'
                });
            }, false, null);
            this.$emit('success', downloadUrl);
        }
    },
    mounted: function () {
        if (!this.btntext)
            this.btntext = col.btnExcel;
    },
    template: '  <btn :text="col.btnExcel" v-on:click="btnExportClick" :linetype="linetype" ></btn> '
})


Vue.component('btn-export-input', {
    props: ['forminline', 'url', 'text', 'linetype'],
    data: function () {
        return {
            btntext: this.text,
        }
    },
    methods: {
        btnExportClick: function () {
            var downloadUrl = "";

            var app = this;
            myAjax("Post", null, this.url, this.forminline, function (result, status, xhr) {
                var fileName = result.data;
                var url = host + "/" + fileName;
                window.open(url);
                app.$message({
                    message: '导出成功!',
                    type: 'success'
                });
            }, false, null);
            this.$emit('success', downloadUrl);
        }
    },
    mounted: function () {
        if (!this.btntext)
            this.btntext = col.btnExcel;
    },
    template: '  <el-button type="primary" v-on:click="btnExportClick" :linetype="linetype" >{{col.btnExcel}}</el-button> '
})

/* 
按钮组件
wust
2019-7-25 18:58:05

例：
     <btn text="查询" ></btn>
     text:显示文字
     imasrc：图标地址 常规的可以不传
     linetype：1 前后都有线 2 前有线 3 后有线 4 前后都无线
     click：触发方法
*/

Vue.component('btn', {
    props: ['text', 'imgsrc', 'linetype', 'click'],
    data: function () {
        return {
            btntype: 'primary',
            dImgsrc: null
        }
    },
    methods: {
        handleClick: function () {
            // 按钮操作处理函数
            this.$emit('click', {})
        }

    },

    created: function () {
        if (this.imgsrc == null || this.imgsrc == '') {
            if (this.text === col.btnSelect) {

                this.imgsrc = "/static/images/search.png";
            }
            else if (this.text === col.btnAdd) {
                this.imgsrc = "/static/images/add.png";

            }
            else if (this.text === col.btnImport) {
                this.imgsrc = "/static/images/import.png";

            }
            else if (this.text === col.btnExcel) {

                this.imgsrc = "/static/images/export.png";
            }
            else if (this.text === col.btnDownLoad) {

                this.imgsrc = "/static/images/download.png";
            }
            else if (this.text === col.btnDelete) {

                this.imgsrc = "/static/images/del.png";
            }
            else {
                this.imgsrc = "/static/images/select.png";
            }

        }
        this.dImgsrc = this.imgsrc;

    },
    //template: '<img v-if="linetype==1||linetype==2" class= "tool-line" src="/static/images/tool-line.png" alt="" >' +
    //    '<img :src="imgsrc" alt="" >' +
    //    '<el-button :type="btntype" > {{text}} </el-button> '+
    //    ' {{text}}<img v-if= "linetype==1||linetype==3" class= "tool-line" src="/static/images/tool-line.png" alt="" > '
    template:
        '<span style="float:left!important"> <img v-if="linetype==1||linetype==2" class="tool-line" src="/static/images/tool-line.png" /><img :src="dImgsrc" /><el-button @click="handleClick" :type="btntype">{{text}}</el-button></img><img v-if= "linetype==1||linetype==3" class= "tool-line" src="/static/images/tool-line.png" /> </span>  '

})



/*list页面工厂列表
 *获取所有除总部外的其他工厂信息当前登录人为总部，全部返回，否则仅返回对应工厂
 */
Vue.component('list-factorys', {
    props: ['value'],
    data: function () {
        return {
            data: [],
            model: this.value
        }
    },
    methods: {
        getdData: function () {
            var url = "/api/WebPageInitial/FactoryList";
            var app = this;
            myAjax("get", this, url, null, function (response) {
                app.data = response.data;

            }, false);

            if (this.data && this.data.length > 0)
                this.model = this.data[0].key;
        },
    },
    mounted: function () {
        this.getdData();
    },
    watch: {
        // 如果 `question` 发生改变，这个函数就会运行
        model: function (newQuestion, oldQuestion) {
            this.$emit('input', newQuestion);
            this.$emit('change', newQuestion);
        },
        value: function (newQuestion, oldQuestion) {
            this.model = newQuestion;
        }
    },
    template: '<el-col :xs="12" :sm="8" :md="6" :lg="6" :xl="6"><div class= "elst-select-mini" ><el-form-item><el-input size="mini"><template slot="prepend">{{"工厂"+mark.m}}</template>'
        + '<el-select @visible-change="visibleChange"  v-model="model"  slot="suffix">'
        + '<el-option v-for="item in data" :label="item.value" :value="item.key"></el-option>'
        + '</el-select>'
        + '</el-input></el-form-item></div ></el-col>'
})

/*list页面工厂列表All
 *获取所有工厂信息，包括总部，当前登录人为总部，全部返回，否则仅返回对应工厂
 */
Vue.component('list-factorys-all', {
    props: ['value'],
    data: function () {
        return {
            data: [],
            model: this.value
        }
    },
    methods: {
        getdData: function () {
            var url = "/api/WebPageInitial/FactoryListAll";
            var app = this;
            myAjax("get", this, url, null, function (response) {
                app.data = response.data;

            }, false);

            if (this.data && this.data.length > 0)
                this.model = this.data[0].key;
        },
    },
    mounted: function () {
        this.getdData();
    },
    watch: {
        // 如果 `question` 发生改变，这个函数就会运行
        model: function (newQuestion, oldQuestion) {
            this.$emit('input', newQuestion);
            this.$emit('change', newQuestion);
        },
        value: function (newQuestion, oldQuestion) {
            this.model = newQuestion;
        }
    },
    template: '<el-col :xs="12" :sm="8" :md="8" :lg="6" :xl="6"><div class= "elst-select-mini" ><el-form-item><el-input size="mini"><template slot="prepend">{{"工厂"+mark.m}}</template>'
        + '<el-select @visible-change="visibleChange"  v-model="model"  slot="suffix">'
        + '<el-option v-for="item in data" :label="item.value" :value="item.key"></el-option>'
        + '</el-select>'
        + '</el-input></el-form-item></div ></el-col>'
})

/*input页面工厂列表
 *获取所有除总部外的其他工厂信息当前登录人为总部，全部返回，否则仅返回对应工厂
 */
Vue.component('input-factorys', {
    props: ['value', 'span', 'offset', 'disabled'],
    data: function () {
        return {
            data: [],
            model: this.value
        }
    },
    methods: {
        getdData: function () {
            var url = "/api/WebPageInitial/FactoryList";
            var app = this;
            myAjax("get", this, url, null, function (response) {
                app.data = response.data;

            }, false);
            if (!this.value)
                return;
            if (this.data && this.data.length > 0)
                this.model = this.data[0].key;
        },
    },
    mounted: function () {
        this.getdData();
    },
    watch: {
        // 如果 `question` 发生改变，这个函数就会运行
        model: function (newQuestion, oldQuestion) {
            this.$emit('input', newQuestion);
            this.$emit('change', newQuestion);
        },
        value: function (newQuestion, oldQuestion) {
            this.model = newQuestion;
        }
    },
    template: ' <el-col :span="span" :offset="offset"> <div class= "elst-select-mini" > <el-form-item> <el-input size="mini"> <template slot="prepend"><div> 工厂</div></template>'
        + '<el-select @visible-change="visibleChange"  v-model="model"  :disabled="disabled" slot="suffix">'
        + '<el-option v-for="item in data" :label="item.value" :value="item.key"></el-option>'
        + '</el-select>'
        + '</el-input></el-form-item ></div></el-col>'

})


/*input页面工厂列表input
 *获取所有工厂信息，包括总部，当前登录人为总部，全部返回，否则仅返回对应工厂
 */
Vue.component('input-factorys-all', {
    props: ['value', 'span', 'offset', 'disabled'],
    data: function () {
        return {
            text_: "工厂",
            data: [],
            model: this.value
        }
    },
    methods: {
        getdData: function () {
            var url = "/api/WebPageInitial/FactoryListAll";
            var app = this;
            myAjax("get", this, url, null, function (response) {
                app.data = response.data;

            }, false);
            if (!this.value)
                return;
            if (this.data && this.data.length > 0)
                this.model = this.data[0].key;
        },
    },
    mounted: function () {
        this.getdData();
        if (this.text)
            this.text_ = this.text;
    },
    watch: {
        // 如果 `question` 发生改变，这个函数就会运行
        model: function (newQuestion, oldQuestion) {
            this.$emit('input', newQuestion);
            this.$emit('change', newQuestion);
        },
        value: function (newQuestion, oldQuestion) {
            this.model = newQuestion;
        }
    },

    template: ' <el-col :span="span" :offset="offset"> <div class= "elst-select-mini" > <el-form-item> <el-input size="mini"> <template slot="prepend"><div> {{text_}}</div></template>'
        + '<el-select @visible-change="visibleChange"  v-model="model" :disabled="disabled" slot="suffix">'
        + '<el-option v-for="item in data" :label="item.value" :value="item.key"></el-option>'
        + '</el-select>'
        + '</el-input></el-form-item ></div></el-col>'

})


var deleteType = {
    deleteSelect: 1,//删除页面选择
    deleteQueryResult: 2//删除查询结果
};
Vue.component('delete-select', {
    props: [
        'value',//弹窗显示控制
        'app',//页面vue对象
        'deleteMuti',//页面删除API Url
        'countUrl',//获取查询结果数量 API Url
        'deleteQueryResultUrl'//删除查询结果 API Url
    ],
    data: function () {
        return {
            selectCount: 0,//已选删除项数量
            queryCount: 0,//当前查询结果数量
            radio: deleteType.deleteSelect,//删除类型
        }
    },
    methods: {
        //删除按钮事件
        onDelete: function () {
            //判断删除类型
            if (this.radio === deleteType.deleteSelect) {
                this.deleteSelect();
            } else {
                this.deleteQueryResult();
            }
        },
        //关闭按钮事件
        handleClose: function () {
            this.value = false;
            this.$emit('input', this.value);
        },
        //窗口弹出事件
        onOpen: function () {
            this.radio = deleteType.deleteSelect;
            var mythis = this;
            myAjax("post", this.app, this.countUrl, this.app.formInline, function (response) {
                mythis.queryCount = response.data;
            }, false);
            mythis.selectCount = this.app.ListItem.tableMultipleSelection.length;

        },
        //删除已选数据
        deleteSelect: function () {
            this.value = false;
            onDelete(this.app, this.deleteMuti);
        },
        //删除查询结果数据
        deleteQueryResult: function () {
            this.value = false;
            DeleteQueryResult(this.app, this.queryCount, this.deleteQueryResultUrl)
        }
    },
    mounted: function () {

    },
    watch: {
        value: function () {
            this.$emit('input', this.value);
        }
    },

    template: '' +
        '<el-dialog title ="提示" :visible.sync="value" @open="onOpen" width="30%" :before-close="handleClose" > ' +
        '<el-radio v-model="radio" :label="deleteType.deleteSelect">删除当前选择内容,共{{selectCount}}条</el-radio>' +
        '<el-radio v-model="radio" :label="deleteType.deleteQueryResult">删除当前查询内容,共{{queryCount}}条</el-radio> ' +
        '<span slot="footer" class="dialog-footer">' +
        '<el-button @click="onDelete">删除</el-button>' +
        '<el-button @click="value = false">取 消</el-button>' +
        ' </span>' +
        '</el-dialog>' +
        ''
})




//1已选 2未选 3划掉
Vue.component('check-box', {
    props: ['value', "label", "text"],
    data: function () {
        return {
            model: false,//check复选状态
            indeterminate: false,//checkindeterminate状态
            modelValue: this.value || "0"//自定义check逻辑值
        }
    },
    methods: {
        change: function (value) {
            switch (this.modelValue) {
                case "2":
                    this.model = false;//未选0
                    this.indeterminate = false;
                    this.modelValue = "0";
                    break;
                case "0":
                    this.model = true;//已选1
                    console.log("this.modelValue2", this.modelValue);
                    this.indeterminate = false;
                    this.modelValue = "1";
                    break;
                case "1":
                    this.model = null;//划出2
                    this.indeterminate = true;
                    this.modelValue = "2";
                    break;
                default:
            }
        },
        init: function (value) {
            console.log(value);
            switch (value + "") {
                case "0":
                    this.model = false;//未选0
                    this.indeterminate = false;
                    this.modelValue = "0";
                    break;
                case "1":
                    this.model = true;//已选1
                    console.log("this.modelValue2", this.modelValue);
                    this.indeterminate = false;
                    this.modelValue = "1";
                    break;
                case "2":
                    this.model = null;//划出2
                    this.indeterminate = true;
                    this.modelValue = "2";
                    break;
                default:
            }
        }
    },
    watch: {
        modelValue: function () {
            this.$emit('input', this.modelValue);
        }
    },
    mounted: function () {
        console.log("this.value", this.value);
        this.init(this.value);
    },
    template: ' <el-checkbox :label="label" v-model="model" @change="change" :indeterminate="indeterminate" >{{text}}</el-checkbox> '

})



Vue.component('select-department', {
    props: ['value'],
    data: function () {
        return {
            options: [],
        }
    },
    methods: {
        getData: function () {
            var app = this;
            myAjax("Post", null, "/api/SysDepartment/GetList", {
                "model": {

                },
                "offset": 0,
                "limit": 10
            }, function (response) {
                var options = response.data.pageData;
                app.options = response.data.pageData;
            }, false);
        }
    },
    watch: {
        value: function () {
            this.$emit('input', this.value);
            this.$emit('change', this.value);
        }
    },
    mounted: function () {
        this.getData();
    },
    template: '<el-select style="margin-top:3px;" v-model="value">' +
        '<el-option v-for= "item in options" :label="item.name" :value = "item.id" ></el-option>' +
        '</el-select>'


})




Vue.component('signature', {
    props: ['value', 'disabled', 'data'],
    data: function () {
        return {
            url: null,
            signId: this.value,
            tooltipContent: "点击取消签名"
        }
    },
    methods: {
        getSignatureImg: function () {
            var app = this;
            if (this.disabled)
                return;
            myAjax("get", null, "/api/user/Signature", null, function (result, status, xhr) {
                var data = result.data;
                app.url = downLoadPath(data.signID)
                app.signId = data.signID
            }, false, null);
            this.inputEvent();
        },

        imgClick: function () {
            if (this.disabled)
                return;
            this.url = null;
            this.signId = null;
            this.inputEvent();
        },
        inputEvent: function () {
            this.$emit('input', this.signId);
            var isCancel = this.signId == null;
            this.$emit('change', this.signId, isCancel, this.data);
        }
    },
    computed: {
        imGIsShow: function () {
            return this.signId != null;
        }
    },
    mounted: function () {
        this.signId = this.value;
        if (this.signId)
            this.url = downLoadPath(this.signId)
    },
    watch: {
        value: function () {
            this.signId = this.value;
            if (this.signId)
                this.url = downLoadPath(this.signId)
        }
    },
    template: '<el-row><el-button style="height:30px"  :disabled="disabled" v-show="!imGIsShow" type="primary" @click="getSignatureImg" icon="el-icon-edit"></el-button></el-tooltip><el-col :span="12">  <el-tooltip :content="tooltipContent" placement="bottom" effect="light"  :disabled="disabled" > <img v-show="imGIsShow"  @click="imgClick" style="width:100px;height:30px" :src="url"/></el-tooltip> </el-col> </el-row>'
})
